#include "../../include/Tileset/tilesetPolyline.hpp"
#include <tinyxml.h>
#include <vector>
#include <string>

namespace Tmx {
  Polyline::Polyline() {
  }
  
  void Polyline::parse(TiXmlNode *polylineNode)
  {
    TiXmlElement *polylineElement= polylineNode->ToElement();
    char *pointsString = strdup(polylineElement->Attribute("points"));
	char *spacePt = strtok(pointsString, " ");
	while (spacePt) {
	  Point pt;
	  sscanf(spacePt, "%d,%d", &pt.x, &pt.y);
	  points.push_back(pt);
	  spacePt = strtok(NULL, " ");
	}
	free(spacePt);
  }
};
